package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.EntprLicenseInfoInsertDTO;
import com.guoheng.hazard.sys.model.dto.entpr.EntprLicenseInfoUpdateDTO;
import com.guoheng.hazard.sys.service.entpr.EntprLicenseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

/**
 * 类功能描述:　EntprLicenseInfoController
 *
 * @author fbl
 * @date 2019-11-12 09:25
 */
@RestController
@Validated
@Api(value = "企业证照信息")
public class EntprLicenseInfoController {

    @Resource
    EntprLicenseInfoService entprLicenseInfoService;

    @ApiOperation(value = "查询企业证照信息")
    @GetMapping(value = "data/basic/document")
    public Result getEntprLicense(Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return entprLicenseInfoService.getEntprLicense(entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改企业证照信息")
    @PutMapping(value = "data/basic/document")
    public Result updateEntprLicense(@RequestBody @Valid EntprLicenseInfoUpdateDTO entprLicenseInfoUpdateDTO) {
        return entprLicenseInfoService.updateEntprLicense(entprLicenseInfoUpdateDTO);
    }

    @ApiOperation(value = "新增企业证照信息")
    @PostMapping(value = "data/basic/document")
    public Result insertEntprLicense(@RequestBody @Valid EntprLicenseInfoInsertDTO entprLicenseInfoInsertDTO) {
        return entprLicenseInfoService.insertEntprLicense(entprLicenseInfoInsertDTO);
    }

    @ApiOperation(value = "删除企业证照信息")
    @DeleteMapping(value = "data/basic/document/{id}")
    public Result deleteEntprLicense(@PathVariable @NotNull Long id) {
        return entprLicenseInfoService.deleteEntprLicense(id);
    }

    @ApiOperation(value = "查询企业证照信息详情")
    @GetMapping(value = "data/basic/document/{id}")
    public Result getEntprLicenseById(@PathVariable @NotNull Long id) {
        return entprLicenseInfoService.getEntprLicenseById(id);
    }
}